package com.yz.lzq.liwushuo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

import com.yz.lzq.liwushuo.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WebActivity extends AppCompatActivity {

    @Bind(R.id.webView_web)
    WebView webViewWeb;
    @Bind(R.id.button_webView_back)
    Button buttonWebViewBack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_web);
        ButterKnife.bind(this);

    }

    @Override
    protected void onResume() {
        super.onResume();
        Intent intent = getIntent();
        String url = intent.getStringExtra("url");
        webViewWeb.loadUrl(url);
        //开启支持js
        webViewWeb.getSettings().setJavaScriptEnabled(true);
        //强制webwebView加载网页
        webViewWeb.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
    }

    @OnClick(R.id.button_webView_back)
    public void onClick() {
        finish();
    }
}
